﻿@using System.Web.Optimization
@using Ed.Common
@using Ed.Entity
@using Ed.Web.Helpers
@model Ed.Entity.TClientInfo
@{
    //客户信息
    //var customer =(TClientInfo) ViewBag.Customer;
    //月嫂信息
    var yuesaoes = (List<TPregnanterInfo>)ViewBag.Yuesao;
    //开始结束时间在隐藏域
    var orderStart = ViewBag.OrderStart;
    var orderEnd = ViewBag.OrderEnd;
    var pricetype = ViewBag.PriceType;
    //订单编号（自动生成）
    var orderCode = RandomHelper.GetOrderNumber();
}
<!doctype html>
<html>
<head>
    <title>雪绒花云服务_订单第三步输入客户信息</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>移动端选择月嫂_雪绒花</title>
    <script type="text/javascript">        //手机机型适配
        if (/Android (\d+\.\d+)/.test(navigator.userAgent)) {
            var version = parseFloat(RegExp.$1);
            if (version > 2.3) {
                var phoneScale = parseInt(window.screen.width) / 640;
                document.write('<meta name="viewport" content="width=640, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
            } else {
                document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
            }
        } else {
            document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
        }</script>
    <script type="text/javascript" charset="utf-8" src="/Themes/default/mobile/jquery-1.10.2.min.js"></script>
    <meta http-equiv="X-UA-Compatible" conte="conte" nt="IE=Edge" />
    @Styles.Render("~/Themes/default/css/cp.globle.min1.css")
    @Scripts.Render("~/Themes/default/js/cp.globle.min1.js")
    <!--省市数据-->
    <script src="/Themes/default/base/js/city.js" type="text/javascript"></script>
    <!--my97DatePicker-->
    <script src="/Themes/default/lib/my97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="/Themes/default/mobile/css/xueronghua.3g.css">
    <script type="text/javascript">
        //=============================================================
        //去除顶层加载中
        $(document).ready(function () {
            //去除加载中
            if (undefined != top.dialog.list["show_loading"]) {
                top.dialog.list["show_loading"].close().remove();
                //showTopMsg("页面加载成功！", "温馨提示", "Success");
            }
        });
        //=====================================================================
    </script>
    <script type="text/javascript">
        $(function () {
            validate_form();
            //选择医院时触发写入值
            $("#HospitalSelect").change(function () {
                var xx = $("#HospitalSelect option:selected").text();
                var yy = $("#HospitalSelect option:selected").val();
                $("#YorderHospital").val(xx);
                $("#YorderHaddress").val(yy);
            });
            //加载省市数据
            load_city_data("ClientProv", "ClientArea", "ClientRegion");
            //
            var now = '@DateTime.Now.ToString("yyyy-MM-dd")';
            $("#ClientBirthday").val(now);
            $("#ClientAge").val(0);
        });
        //表单验证
        function validate_form() {
            $("#step4_form").validate({
                errorPlacement: function (error, element) {
                    var errorMsg = error[0].innerHTML;
                    var elementName = element[0].name;
                    $("#" + elementName).formtip(errorMsg);
                    //showMsg(errorMsg, "错误提示", "Error");
                    $("#" + elementName).attr("placeholder", errorMsg);
                },
                success: function (element) {
                    var elem = $(element)[0].htmlFor;
                    $("#" + elem).poshytip('disable');
                    $("#" + elem).poshytip('destroy');
                    $("#" + elem).removeClass("error").addClass("success");
                    //身份证号码生成生日
                    if (elem == "ClientIdcard") {
                        idcard_to_birth_age($.trim($("#" + elem).val()));
                    }

                }
            });
        }
        //身份证生成生日和年龄
        function idcard_to_birth_age(cardNum) {
            if (isChinaIDCard(cardNum)) {
                var bir = get_birthday_by_idcard(cardNum);
                var now = '@DateTime.Now.ToString("yyyy-MM-dd")';
                var age = YearDiff(bir, now);
                $("#ClientBirthday").val(bir);
                $("#ClientAge").val(age);
            }
        }
    </script>
    <script type="text/javascript">

        function submit_order() {
            if (!$("#step4_form").valid()) {
                return false;
            }
            //var data = $(client_form).serializeObject();
            var data = $("#step4_form").serialize();
            console.log(data);
            //return;
            $.ajax({
                type: "POST",
                cache: false,
                url: "/api/YuesaoOrderApi/AddYuesaoOrder",
                data: data,
                dataType: "json",
                beforeSend: function () {
                    //显示加载中
                    showTopDialog("show_loading", "<section class='dialog_loading'>月嫂订单添加中，请稍后...</section>", "温馨提示", 400, 95);
                },
                complete: function () {
                },
                success: function (result) {
                    top.dialog.list["show_loading"].close().remove();
                    //toLowerCase报错
                    //var status = result.Status.toLowerCase();
                    var status = result.Status;
                    if (status == true || status == "true" || status == "True") {
                        //刷新数据
                        show_order_success();
                    } else {
                        showMsg("系统异常，订单添加失败！", "Error");
                    }
                },
                error: function () {
                    top.dialog.list["show_loading"].close().remove();
                    showMsg("网络连接错误!", "错误提示", "Error");
                }
            });
            //必须有这个，阻止刷新
            return false;
        }
        //预定成功
        function show_order_success() {
            alert("恭喜你，成功添加月嫂订单！");
        }
    </script>
    <script type="text/javascript">
        function pregnanterinfo_view(id) {
            var url = window.location.href;
            location.href = "/Yuesao/PregnanterInfo/MobileView?id=" + id;
        }
    </script>
<style type="text/css">
.h_tit{color:#fff; font-size:30px; background-color:orange;padding-left:30px; height:60px; line-height:60px;}
.yixiang b{color:red;}
.yuesaoinfo span{ line-height:60px; background:#FF6; font-size:18px;}
.form-control{ padding:10px 12px; height:auto; width:auto; font-size:20px;}
.b_left{ float:left; width:140px; text-align:right; margin-top:10px;}
.b_right{float:right; width:490px; margin-top:10px;}
.clear{ clear:both;}
</style>
</head>
<body style="background-color:#fff;"> 
        <section class="form-container" id="form_container">
        <section class="ng-form-area show-place" id="form-area">
        
        <form method="post" id="step4_form">
                  <section class="h_tit">月嫂信息</section> 
                   
                   <section  class="yixiang"> 预定时间： 
                   <input type="hidden" id="OrderBegin" name="OrderBegin" value="@orderStart" />
                   <input type="hidden" id="OrderEnd" name="OrderEnd" value="@orderEnd" />                  
                   (开始)<b>@orderStart</b> - (结束)<b>@orderEnd</b></section>
                    <section class="yuesaoinfo">
                        意向月嫂：
                          @foreach (var yuesao in yuesaoes)
                          {
                                <input type="hidden"  name="YorderAlter" value="@yuesao.Id" />
                                <span>@yuesao.PInfoName @pricetype</span>
                                if (@pricetype == "12时")
                                { <b>@yuesao.PInfoPrice12</b>}
                                else
                                { <b>@yuesao.PInfoPrice</b>}
                          }
                        <input type="hidden" id="YorderPtype" name="YorderPtype" value="@pricetype" />
                    </section>             
                    <section class="h_tit">订单信息</section>             
                    <!---隐藏值-->
                    <input type="hidden" id="OrderCode" name="OrderCode" value="@orderCode" />
                  <section class="b_left">预产医院：</section>
                  <section class="b_right">
                  <select value="1" class="form-control" id="HospitalSelect" name="HospitalSelect"
                            placeholder="" onChange="hospitalselect()">
                            <option value="">请选择</option>
                            <option value="河南省郑州市二七区康复前街7号" alt="">郑州大学三附院产科</option>
                            <option value="郑州市金水路41号">郑州市妇幼保健院</option>
                            <option value="郑州市金水区黄河路33号">郑州人民医院</option>
                            <option value="郑州市经八路2号">郑州大学第二附属医院三级甲等医院</option>
                            <option value="河南省郑州市文化宫路65号">郑州市中医院三甲</option>
                            <option value="河南省郑州市东大街56号">郑州第一人民医院产科</option>
                            <option value="郑州市郑东新区农业东路3号(中州大道与农业路交汇往东)">郑州圣玛妇产医院</option>
                            <option value="郑州市管城区南顺城街136号">郑州第三人民医院</option>
                            <option value="郑州市金水区群办路13">郑州大桥医院</option>
                            <option value="郑州市桐柏路中段195号">郑州市中心医院</option>
                   </select>  
                   </section>                                       
                    <section class="clear"></section>
                    
                    <section class="b_left">
                        <span class="must">*</span>预产期 ：
                        </section>
                        <section class="b_right">                
                           <input value="@orderStart" class="form-control Wdate dateISO required" data-val="true" data-val-date="填入正确格式"
                            id="YorderChildbirth" maxlength="10" minlength="10" name="YorderChildbirth" onClick="WdatePicker()"
                            type="text">
                    </section>
                   <section class="clear"></section>
                   
                   <section class="b_left"><span class="must">*</span>胎数：</section>
                   <section class="b_right">
                        <select value="1" class="form-control required valid success" id="YorderCode" name="YorderCode"
                            placeholder="">
                            <option value="">请选择</option>
                            <option selected="selected" value="1">一胎</option>
                            <option value="2">二胎</option>
                            <option value="3">三胎</option>
                        </select>
                    </section>
                    <section class="clear"></section>
                        
                        
                     <section class="b_left">预产医院：</section>
                     <section class="b_right">  
                            <input class="form-control" id="YorderHospital" name="YorderHospital" placeholder="预产医院"
                                style="width:90%;" type="text" value="" />
                     </section>
                     <section class="clear"></section>
                      
                     <section class="b_left">医院地址：</section>
                     <section class="b_right">                                   
                            <input class="form-control" id="YorderHaddress" name="YorderHaddress" placeholder="医院详细地址"
                                style="width: 100%;" type="text" value="" />
                     </section>
                      <section class="clear"></section>
                      
                      
                   <section class="b_left">详细要求：</section>    
                   <section class="b_right">        
                        <textarea class="form-control" cols="4" id="YorderRequire" maxlength="200" minlength="1"hjjj
                            name="YorderRequire" rows="2" style="width:100%;"></textarea>
                  </section>
                  <section class="clear"></section>
                  
              <section class="b_left">下单相关：</section>
              <section class="b_right">
              <input type="hidden" id="OrderCreater" name="OrderCreater" value="@Session[EdKeys.SESSION_USER_ID]" />
              @Session[EdKeys.SESSION_USER_NAME] @DateTime.Now.ToString("yyyy-MM-dd")
              </section>
               <section class="clear"></section>
               
                <section class="h_tit">客户信息</section>                    
                    <!--客户id-->
                    @Html.HiddenFor(model => model.Id)
                    @Html.HiddenFor(model => model.ClientCode, new { @class = "form-control isreadonly", @style = "width: 200px; color:red;font-weight:bold;", @placeholder = "系统自动生成", @onfocus = "this.blur();" })
                 
                    <section class="b_left"><span class="must">*</span>客户姓名：</section>
                    <section class="b_right"><input class="form-control required" id="ClientName" name="ClientName" placeholder="姓名"
                            style="width:300px;" type="text" value="" minlength="1" maxlength="16" />
                    </section>
                    <section class="clear"></section>
                    
                    <section class="b_left"><span class="must">*</span>联系手机：</section>
                    <section class="b_right">
                        <input class="form-control required" id="ClientTel" name="ClientTel" placeholder="手机号码"
                            minlength="11" maxlength="11" style="width:400px;" type="text" value="" />
                      </section>
                    <section class="clear"></section>
                    
                    <section class="b_left">所属民族：</section>
                    <section class="b_right">
                          <input class="form-control required CHS" id="ClientNational" name="ClientNational" placeholder="汉族"
                            style="width:200px;" type="text" value="汉族" />
                        <select value="1" class="form-control valid success" id="ClientSex" name="ClientSex"
                            placeholder="" style="width:180px;">
                            <option value="">请选择</option>
                            <option value="1" alt="">女</option>
                            <option value="2">男</option>
                        </select>
                    </section>
                   <section class="clear"></section>
                   
                   <section class="b_left">身份证号 ：</section>
                    <section class="b_right">
                        <input class="form-control idcard" id="ClientIdcard" name="ClientIdcard" placeholder="可自动生成生日及年龄"
                            type="text" style="width:400px;" value="" />
                    </section>
                    <section class="clear"></section>
                    
                    <section class="b_left">客户生日：</section>
                    <section class="b_right">
                        <input class="form-control isreadonly" id="ClientBirthday" name="ClientBirthday"
                            placeholder="客户生日" style="width:240px;" type="text" value="" onFocus="this.blur();" />
                        <input class="form-control isreadonly" id="ClientAge" name="ClientAge" placeholder="年龄"
                            style="width:100px;" type="text" value="" onFocus="this.blur();" />岁
                   </section>
                   <section class="clear"></section>
                   
                   <section class="b_left">家庭住址：</section>
                  <section class="b_right">
                        <select id="ClientProv" name="ClientProv" style="width: 130px;" class="form-control">
                            <option value="0" selected="selected">请选择</option>
                        </select>
                        <select id="ClientArea" name="ClientArea" style="width: 130px;" class="form-control">
                            <option value="0" selected="selected">请选择</option>
                        </select>
                        <select id="ClientRegion" name="ClientRegion" style="width: 130px;" class="form-control">
                            <option value="0">请选择</option>
                        </select>
                   </section>
                   <section class="clear"></section>
                   
                   <section class="b_left">详细地址：</section>
                   <section class="b_right">
                        <input class="form-control" id="ClientAddress" name="ClientAddress" placeholder="详细地址"
                            style="width:90%;" type="text" value="" />
                 	</section>
                    <section class="clear"></section>
            </form>
        </section>
        </section>
        
        <section style=" margin-top:20px;">
            <button type="button" class="btn btn-primary btn-lg btn-block teshu"  onClick="submit_order();">
                确认无误，并生成订单信息
            </button>
        </section> 
</body>
</html>
